<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        main{
            height: 300px;
            width: 300px;
            background-image: radial-gradient(circle,gray,green,blue);
            border-radius: 50%;
            padding: 100px 0;
            box-sizing: border-box;
            margin: 0 auto;
        }
        div{
            width: 260px;
            margin: 0 auto;
        }
        .topd{
            height: 100px;
            border: solid 2px black;
            text-align: center;
            line-height: 100px;
            font-size: 30px;
            background-color: navajowhite;
        }
        .topt{
            float: right;
            margin-right: 25px;
            text-align: right;
        }
    </style>
</head>
<body>
    <main>
        <div class="topt" id="up"></div>
        <div class="topd" id="down"></div>
    </main>
</body>
</html>
<script>
    function method(){
        var date1 = new Date();//实例化日期
        var year = date1.getFullYear();//年
        var month = date1.getMonth();//月
        var date =date1.getDate();
        var day = date1.getDay();//星期
        var hours = date1.getHours();//小时
        var minutes = date1.getMinutes();//分钟
        var seconds = date1.getSeconds();//miao
        switch(day){
            case 1:day ='一';break;
            case 2:day ='二';break;
            case 3:day ='三';break;
            case 4:day ='四';break;
            case 5:day ='五';break;
            case 6:day ="六";break;
            default:day ="日";break;
        }
        hours = hours>10?hours:"0"+hours;
        minutes = minutes>10?minutes:"0"+minutes;
        seconds = seconds>10?seconds:"0"+seconds;
        console.log(day);
        document.getElementById("up").innerHTML=year+"年"+month+"月"+date+"日"+"星期"+day;
        document.getElementById("down").innerHTML=hours+"小时"+minutes+"分钟"+seconds+"秒";
    }
   setInterval(method,1000);
// method();
</script>